#include <iostream>
using namespace std;

typedef struct node
{
    int data;
    struct node *next;

    void printEach()
    {
        auto cur = this;
        while (cur)
        {
            cout << "data is  " << cur->data << endl;
            cur = cur->next;
        }
    }
} Node, *LinkList;

Node *CreateLinkedList(int a[], int n)
{
    LinkList head = (Node *)malloc(sizeof(Node));
    head->next = NULL;
    for (int i = n; i > 0; i--)
    {
        LinkList p = (Node *)malloc(sizeof(Node));
        p->data = a[i - 1];
        p->next = head->next;
        head->next = p;
    }
    return head;
}
int main(int argc, const char *argv[])
{
    int a[5] = {12, 3, 5, 7, 11};
    auto h = CreateLinkedList(a, 5);

    h->next->printEach();
    // while (h->next != NULL)
    // {
    //     cout << "data is  " << h->next->data << endl;
    //     h = h->next;
    // }
}